package cn.nkjobsearch.action;

import java.util.ArrayList;
import cn.nkjobsearch.jena.NKJSJena;
import com.opensymphony.xwork2.ActionSupport;
import cn.nkjobsearch.convert.City;

public class AjaxCityAction extends ActionSupport
{
	private String city;
    private String result = "";

    // ajax请求参数赋值
    public void setCity(String city) 
    {
        this.city = city;
    }
    // ajax返回结果
    public String getResult() 
    {
        return result;
    }
    public String execute() 
    {
    	NKJSJena jn = new NKJSJena();
    	ArrayList<Integer> rs = new ArrayList<Integer>();
		rs = jn.findCity(City.getCityCode(city), false);
		this.result += "<br>输入城市：【"+ city +"】<br>城市扩展：";
		if( 0 == rs.size())
			this.result +=" 没有相关扩展信息！";
		else
		{
	    	for (int i = 0; i < rs.size(); i++) 
	    	{
				this.result +=" <input type=checkbox name=\"extendCity\" value=\""+rs.get(i)+"\"> "
							+ City.getCityViaCode(rs.get(i))
							+" ";
	    	}
		}
		rs = null;
		return SUCCESS;
    }
}
